﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CommerceOne.Domains.UnBoundEnities;
using CommerceOne.Models;
using CommerceOne.Widgets.LeftBrandNav;
using CommerceOne.Widgets.LeftCategoryNav;

namespace CommerceOne.Controllers
{
    public class ControllerBase : Controller
    {
        public void CommonInitialize(ViewModelBase viewModelBase)
        {
            if (viewModelBase == null) return;
            
            // Init Left category controller
            LeftCategoryNavController leftCategoryNavController = new LeftCategoryNavController();
            viewModelBase.LeftCategoryNavViewModel =  leftCategoryNavController.GetViewModel();

            // Init Left brand controller
            LeftBrandNavController leftBrandNavController = new LeftBrandNavController();
            viewModelBase.LeftBrandNavViewModel = leftBrandNavController.GetViewModel();

            Cart cart = Session["Cart"] as Cart;
            if (cart != null) viewModelBase.ItemNumber = cart.ComputeTotalItem();

        }
    }
}